package com.wedata.中台服务;

import cn.hutool.crypto.digest.MD5;
import cn.hutool.json.JSONObject;
import com.wedata.HttpUtils;

import java.util.ArrayList;
import java.util.List;

public class UserCenter {

    public static void main(String[] args) {
        会员注册();
    }
    public static void getLoginTokent() {
        String uri = "https://twedata.gymcity.com.cn/ucenter/user/getSourceLogin";

        JSONObject body = new JSONObject("{\"source\":\"gym3\",\"source_uid\":246689,\"to_source\":\"gym3\"}",true,false);
        System.out.println(body);

        String sign = MD5.create().digestHex(body+"#bcdd91ca0bf447d4df610616e00980c9");
        System.out.println(sign);
        JSONObject header = new JSONObject("{\"X-TRACEID\":\"uuid\",\"X-APPKEY\":\"95695139068\",\"X-SIGN\":\""+sign+"\"}");
        Long s = System.currentTimeMillis();
        System.out.println(HttpUtils.sendPost(uri,header,body)+":"+(System.currentTimeMillis()-s));
    }

    public static void getLoginToken() {
        String uri = "https://ucenter.gymcity.com.cn/ucenter/user/getSourceLogin";

        JSONObject body = new JSONObject("{\"source\":\"gym3\",\"source_uid\":15878,\"to_source\":\"shop\"}",true,false);
        System.out.println(body);

        String sign = MD5.create().digestHex(body+"#sUOpMGcl7D0LXo1VxN9356bSqi2IwTKA");
        System.out.println(sign);
        JSONObject header = new JSONObject("{\"X-TRACEID\":\"uuid\",\"X-APPKEY\":\"45971806233\",\"X-SIGN\":\""+sign+"\"}");
        Long s = System.currentTimeMillis();
        System.out.println(HttpUtils.sendPost(uri,header,body)+":"+(System.currentTimeMillis()-s));
    }
    public static void getGym3Member() {
        String uri = "https://ucenter.gymcity.com.cn/ucenter/user/getGym3Member";

        JSONObject body = new JSONObject("{\"from_source\":\"btw\",\"from_source_uids\":[632851],\"to_source\":\"gym3\"}",true,false);
        System.out.println(body);

        String sign = MD5.create().digestHex(body+"#sUOpMGcl7D0LXo1VxN9356bSqi2IwTKA");
        System.out.println(sign);
        JSONObject header = new JSONObject("{\"X-TRACEID\":\"uuid\",\"X-APPKEY\":\"45971806233\",\"X-SIGN\":\""+sign+"\"}");
        Long s = System.currentTimeMillis();
        System.out.println(HttpUtils.sendPost(uri,header,body)+":"+(System.currentTimeMillis()-s));
    }


    public static void 测试签名() {
        String uri = "https://twedata.gymcity.com.cn/ucenter/user/getGym3Member";

        JSONObject body = new JSONObject("{\"from_source\":\"btw\",\"from_source_uids\":[180778],\"to_source\":\"gym3\"}",true,false);
        System.out.println(body);

        String sign = MD5.create().digestHex(body+"#bcdd91ca0bf447d4df610616e00980c9");
        JSONObject header = new JSONObject("{\"X-TRACEID\":\"uuid\",\"X-APPKEY\":\"95695139068\",\"X-SIGN\":\""+sign+"\"}");
        Long s = System.currentTimeMillis();
        System.out.println(HttpUtils.sendPost(uri,header,body)+":"+(System.currentTimeMillis()-s));
    }

    public static void 本地签名() {
        String uri = "http://localhost:8084/ucenter/user/getGym3Member";

        JSONObject body = new JSONObject("{\"from_source\":\"btw\",\"from_source_uids\":[560540],\"to_source\":\"gym3\"}",true,false);
        System.out.println(body);

        String sign = MD5.create().digestHex(body+"#bcdd91ca0bf447d4df610616e00980c9");
        System.out.println(sign);
        JSONObject header = new JSONObject("{\"X-TRACEID\":\"uuid\",\"X-APPKEY\":\"95695139068\",\"X-SIGN\":\""+sign+"\"}");
        Long s = System.currentTimeMillis();
        System.out.println(HttpUtils.sendPost(uri,header,body)+":"+(System.currentTimeMillis()-s));
    }

    public static void 签名失败的问题() {
        String uri = "https://ucenter.gymcity.com.cn/ucenter/user/getGym3Member";

        JSONObject body = new JSONObject("{\"from_source\":\"btw\",\"from_source_uids\":[2224273,2224253,2224031,60105,59603,2224059,2221619,275974,824043,59516,2221624,55262,290969,1440405],\"to_source\":\"gym3\"}");
        System.out.println(body);

        String sign = MD5.create().digestHex(body+"#sUOpMGcl7D0LXo1VxN9356bSqi2IwTKA");
        System.out.println(sign);
        JSONObject header = new JSONObject("{\"X-TRACEID\":\"uuid\",\"X-APPKEY\":\"45971806233\",\"X-SIGN\":\""+sign+"\"}");
        Long s = System.currentTimeMillis();
        System.out.println(HttpUtils.sendPost(uri,header,body)+":"+(System.currentTimeMillis()-s));
    }

    public static void xxx() {
        // 这里是绑定注册失败的数据修正，
        String usids = "2182058,2182059,2182060,2182061,2182062,2182063,2182064,2182065,2182066,2182067,2182068,2182069,2182070,2182071,2182072,2182073,2182074,2182075,2182076,2182077,2182078,2182079,2182080,2182081,2182082,2182083,2182084,2182085,2182086,2182087,2182088,2182089,2182090,2182091,2182092,2182093,2182094,2182095,2182096,2182097,2182098,2182099,2182100,2182101,2182102,2182103,2182104,2182105,2182106,2182107,2182108,2182109,2182110,2182111,2182112,2182113,2182114,2182115,2182116";
        String[] sids = usids.split(",");
        for(String sid : sids){
            String uri = "https://ucenter.gymcity.com.cn/ucenter/user/getSourceUid";
            JSONObject body = new JSONObject("{\"from_source_uid\":"+sid+",\"to_source\":\"shop\",\"source\":\"btw\",\"from_source\":\"btw\"}");
            System.out.println(body);

            String sign = MD5.create().digestHex(body+"#sUOpMGcl7D0LXo1VxN9356bSqi2IwTKA");
            JSONObject header = new JSONObject("{\"X-TRACEID\":\"uuid\",\"X-APPKEY\":\"45971806233\",\"X-SIGN\":\""+sign+"\"}");
            Long s = System.currentTimeMillis();
            System.out.println(HttpUtils.sendPost(uri,header,body)+":"+(System.currentTimeMillis()-s));
        }

        /*String sign = MD5.create().digestHex(body+"#bcdd91ca0bf447d4df610616e00980c9");
        JSONObject header = new JSONObject("{\"X-TRACEID\":\"uuid\",\"X-APPKEY\":\"95695139068\",\"X-SIGN\":\""+sign+"\"}");*/


    }

    public static void 会员注册() {
        String uri = "https://twedata.gymcity.com.cn/ucenter/user/register";
        //String uri = "http://localhost:8084/ucenter/user/register";

        //JSONObject body = new JSONObject("{\"source\":\"btw\",\"source_uid\":\"81735022\",\"mobile\":\"18867363985\",\"areacode\":\"86\",\"virtual_phone\":1,\"nickname\":\"杨林\",\"head_image\":\"https://thirdwx.qlogo.cn/mmopen/vi_32/5hSlgIqboZQjSmTHibIAEgZqlN0XnBMhG32LHOs71OkAZNCMuaZPRXKCj24bhO9Q2ibb5pRpJsh02Zcp4FF5W4gq9ibHXohzOCZqPVfaNqolw4/132\"}");
        //JSONObject body = new JSONObject("{\"source\":\"btw\",\"source_uid\":\"81735022\",\"mobile\":\"18867363985\",\"areacode\":\"86\",\"virtual_phone\":1,\"wechat_openid\":\"o-STI56BGGSqi9Q5152LpVCB-E_4\",\"wechat_unionid\":\"oCDSO1kDmb5GF9SpA5VQTTwoLi9M\",\"nickname\":\"杨林\",\"head_image\":\"https://thirdwx.qlogo.cn/mmopen/vi_32/5hSlgIqboZQjSmTHibIAEgZqlN0XnBMhG32LHOs71OkAZNCMuaZPRXKCj24bhO9Q2ibb5pRpJsh02Zcp4FF5W4gq9ibHXohzOCZqPVfaNqolw4/132\"}");
        JSONObject body = new JSONObject("{\"source\":\"btw\",\"source_uid\":\"2357194\",\"mobile\":\"18530924090\",\"areacode\":\"+86\",\"virtual_phone\":1}");
        System.out.println(body);

        String sign = MD5.create().digestHex(body+"#bcdd91ca0bf447d4df610616e00980c9");
        JSONObject header = new JSONObject("{\"X-TRACEID\":\"uuid\",\"X-APPKEY\":\"95695139068\",\"X-SIGN\":\""+sign+"\"}");
        Long s = System.currentTimeMillis();
        System.out.println(HttpUtils.sendPost(uri,header,body)+":"+(System.currentTimeMillis()-s));
    }

    public static void yy() {
        //String uri = "http://192.168.0.142:8084/ucenter/user/getSourceUid";
        //String uri = "https://twedata.gymcity.com.cn/ucenter/user/getUidBySourceUid";
        //String uri = "http://192.168.0.142:8084/ucenter/user/getUidBySourceUid";
        //String uri = "https://twedata.gymcity.com.cn/ucenter/user/getUidBySourceUid";

        String uri = "https://ucenter.gymcity.com.cn/ucenter/user/register";
        ////{"code":401,"msg":"X-APPKEY 不存在,验证不通过","data":null,"time":1697074833}:119
        //{"code":401,"msg":"签名不一致,验证不通过","data":null,"time":1697074883}:108
        //{"code":0,"msg":"操作成功","data":{"uid":1064564,"source_uid":1062942},"time":1697076986}:130

        /*String uri = "http://ucenter.gymcity.com.cn:8084/ucenter/user/getUidBySourceUid";
        JSONObject body = new JSONObject("{\"from_source\":\"btw\",\"from_source_uid\":81735496}");*/
        //{"code":0,"msg":"操作成功","data":1064564,"time":1697075405}:562

        //String uri = "http://ucenter.gymcity.com.cn:8084/ucenter/user/changeMobile";
        //{"code":-102,"msg":"修改后的手机号用户中心已存在","data":null,"time":1697075750}:567
        //{"code":0,"msg":"操作成功","data":true,"time":1697075840}:1116
        //{"code":0,"msg":"操作成功","data":true,"time":1697075954}:561  -- 三分钟内走的索引

        //String uri = "https://ucenter.gymcity.com.cn/ucenter/user/getSourceUid";
        //String uri = "https://twedata.gymcity.com.cn/ucenter/user/getSourceUid";

        //JSONObject body = new JSONObject("{\"areacode\":86,\"email\":\"1@qq.com\",\"gender\":1,\"idno\":\"430903198710081345\",\"mobile\":\"19974915020\",\"nickname\":\"\",\"realname\":\"杨林\",\"source\":\"btw\",\"source_uid\":5,\"wechat_openid\":\"\",\"wechat_unionid\":\"\"}");
        //JSONObject body = new JSONObject("{\"appid\":\"9v7jzUKN5LIpdkiW\",\"secret_key\":\"J1xyf245t87TMjUICGZiLeHkdbpSPKYu\",\"source\":\"btw\",\"from_source\":\"btw\",\"from_source_uid\":81735127,\"to_source\":\"gym3\"}");
        //JSONObject body = new JSONObject("{\"from_source\":\"btw\", \"from_source_uid\":16857, \"source\":\"tag\"}");
        //JSONObject body = new JSONObject("{\"areacode\":86,\"email\":\"1@qq.com\",\"gender\":1,\"idno\":\"430903198710081345\",\"mobile\":\"17521745605\",\"nickname\":\"\",\"realname\":\"潘智\",\"source\":\"shop\",\"source_uid\":1062942,\"wechat_openid\":\"\",\"wechat_unionid\":\"\"}");
        //JSONObject body = new JSONObject("{\"from_source\":\"shop\",\"from_source_uid\":1062942}");
        //JSONObject body = new JSONObject("{\"source\":\"shop\",\"areacode\":86,\"source_uid\":1062942,\"mobile\":\"18867363985\",\"old_areacode\":\"86\",\"old_mobile\":\"17521745605\",\"request_type\":1}");

        //JSONObject body = new JSONObject("{\"source\":\"btw\",\"source_uid\":\"1262328\",\"mobile\":\"15311429913\",\"areacode\":\"86\",\"virtual_phone\":1}");
        //String str = "1262268,19856596948,86;1262269,19528848346,86;1262270,11114447777,86;1262271,17328484116,86;1262272,18075156663,86;1262273,18804058696,86;1262274,15652587291,86;1262275,13287688022,86;1262276,09650188886,95;1262277,18403600020,86;1262279,13226960951,86;1262280,17330568632,86;1262281,17628039276,86;1262282,18184035520,86;1262283,13361280423,86;1262284,13644003813,86;1262285,15125386307,86;1262286,17663577538,86;1262287,17796842553,86;1262288,15363885786,86;1262289,18727001931,86;1262290,15010539836,86;1262291,17880960933,86;1262292,15503660880,86;1262293,15038550107,86;1262294,13551052896,86;1262295,13877999887,86;1262296,15369271518,86;1262297,15547253667,86;1262298,18257133302,86;1262299,13665819975,86;1262300,13732297277,86;1262301,13227592682,86;1262302,13671954321,86;1262303,18259953607,86;1262304,18396996523,86;1262305,13538054141,86;1262306,17779606231,86;1262307,13765117549,86;1262308,13725502364,86;1262309,13177056825,86;1262310,15810462959,86;1262311,19158265558,86;1262312,15829502727,86;1262313,13827555744,86;1262314,15917293301,86;1262316,17841279673,86;1262317,18825540645,86;1262318,13327455380,86;1262319,13798400555,86;1262320,18020448211,86;1262321,13815571080,86;1262322,13672567666,86;1262323,15970058002,86;1262324,13329404152,86;1262325,17396898879,86;1262327,13822659017,86";

        //String uri = "https://twedata.gymcity.com.cn/ucenter/user/getUidBySourceUids";

        //JSONObject body = new JSONObject("{\"from_source\":\"btw\",\"to_source\":\"gym3\",\"from_source_uid\":358218}");

        JSONObject body = new JSONObject("{\"source_uid\":225066,\"mobile\":\"17872666471\",\"areacode\":\"86\",\"source\":\"gym3\"}");

        String sign = MD5.create().digestHex(body+"#sUOpMGcl7D0LXo1VxN9356bSqi2IwTKA");
        JSONObject header = new JSONObject("{\"X-TRACEID\":\"uuid\",\"X-APPKEY\":\"45971806233\",\"X-SIGN\":\""+sign+"\"}");
        /*String sign = MD5.create().digestHex(body+"#bcdd91ca0bf447d4df610616e00980c9");
        JSONObject header = new JSONObject("{\"X-TRACEID\":\"uuid\",\"X-APPKEY\":\"95695139068\",\"X-SIGN\":\""+sign+"\"}");*/

        Long s = System.currentTimeMillis();
        System.out.println(HttpUtils.sendPost(uri,header,body)+":"+(System.currentTimeMillis()-s));


    }


}
